package benchmark

type Report struct {
	Image               string  `json:"image"`
	NormalStartupSec    float64 `json:"normal_startup_sec"`
	OnyxStartupSec      float64 `json:"onyx_startup_sec"`
	SpeedupRatio        float64 `json:"speedup_ratio"`
	CacheHitRatePercent float64 `json:"cache_hit_rate_percent"`
	DownloadedBlocks    int     `json:"downloaded_blocks"`
	CacheSizeMB         float64 `json:"cache_size_mb"`
}

func CompareResults(normal, onyx *Metrics) *Report {
	hitRate := float64(onyx.CacheHit) / float64(onyx.CacheHit+onyx.CacheMiss+1)
	return &Report{
		Image:               onyx.Image,
		NormalStartupSec:    normal.StartupDuration.Seconds(),
		OnyxStartupSec:      onyx.StartupDuration.Seconds(),
		SpeedupRatio:        normal.StartupDuration.Seconds() / onyx.StartupDuration.Seconds(),
		CacheHitRatePercent: hitRate * 100,
		DownloadedBlocks:    onyx.BlocksDownloaded,
		CacheSizeMB:         float64(onyx.CacheSizeBytes) / 1024.0 / 1024.0,
	}
}
